package com.atguigu.springboot.mapper;

import com.atguigu.springboot.entity.Department;
import org.apache.ibatis.annotations.*;

/**
 * @author : wenchao.long
 * @date : Created in 2020/11/26 10:14 周四
 * @description :
 */
public interface DepartmentMapper {
    /**
     * 通过id查询
     *
     * @param id id
     * @return Department
     */
    @Select("select * from `department` where id=#{id}")
    Department getById(Integer id);

    /**
     * 通过id删除
     *
     * @param id id
     */
    @Delete("delete from department where id=#{id}")
    void deleteById(Integer id);

    /**
     * 插入
     *
     * @param department department
     */
    @Options(useGeneratedKeys = true)
    @Insert("insert into department(department_name) values(#{departmentName})")
    void insert(Department department);

    /**
     * 修改
     *
     * @param department department
     */
    @Update("update department set department_name=#{departmentName} where id=#{id}")
    void update(Department department);
}
